# -*- coding: utf-8 -*-
# @Time : 2023/12/1 14:03
# @Author : 支晓光
# @Email : 1473858993@qq.com
# @File : unfollor.py
# @Project : YouGuuUII
import logging
from time import sleep

from appium.webdriver.common.appiumby import AppiumBy

from common.base_page import BasePage


class UnFollor(BasePage):

    # 头像
    head_pic = AppiumBy.ID, 'com.jhss.youguu:id/head_pic'
    # 关注
    btn_focus = AppiumBy.ID, 'com.jhss.youguu:id/btn_focus'
    # 关注列表
    nickNameView= AppiumBy.ID,'com.jhss.youguu:id/nickNameView'
    # 关注数字
    tv_focus_num = AppiumBy.ID,'com.jhss.youguu:id/tv_focus_num'
    # 取消关注
    commontAttText = AppiumBy.ID,'com.jhss.youguu:id/commontAttText'
    # 返回上一层
    ImageButton = AppiumBy.ID,'android.widget.ImageButton'
    def unfollor(self):
        # 点击头像
        self.click_ele(self.head_pic)
        # 查询数字
        self.num = int(self.find_element(self.tv_focus_num).text)
        # 点击关注列表
        self.click_ele(self.btn_focus)
        # 判断已关注数字大于1
        if self.num<1:
            self.status = 1
            pass
        # 如果只有一个关注人员
        elif self.num == 1:
            sleep(3)
            # 点击取消关注
            self.tap(999, 199)
            # 取消点击后关注数量
            self.num_know = 0
        else:
            sleep(3)
            # 点击取消
            self.tap(999,199)
            # 关注状态
            self.status = self.find_elements(self.commontAttText)[0].text
            # 取消关注后关注的数量
            self.num_know = self.num-1
